package reflect;


import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getMethod("say", String.class, int.class);

        String name = method.getName();
        System.out.println("方法名："+name);

        Class returnType = method.getReturnType();
        System.out.println("方法的返回值类型为："+returnType);

        int count =method.getParameterCount();
        System.out.println("方法共："+count+"个参数");

        int modifiers = method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("是一个public方法");
                break;
            case Modifier.PRIVATE:
                System.out.println("是个一个private方法");
                break;
            case Modifier.PROTECTED:
                System.out.println("是一个protected方法");
            default:
                System.out.println("是一个默认方法");
        }

    }
}
